mixin ProviderLib {
  late Map<String, dynamic> _providerLibData;
  late Function _notify;
  late Function? _persistSave;

  providerInit(
    Map<String, dynamic> data, {
    required Function notify,
    Function? persistSave,
  }) {
    this._providerLibData = data;
    this._persistSave = persistSave;
    this._notify = notify;
  }

  T get<T>(String key) {
    return _providerLibData[key];
  }

  set({
    required String key,
    required dynamic value,
  }) {
    _notify();
    _providerLibData[key] = value;
    _persistSave!(_providerLibData);
  }

  setAll(Map<String, dynamic> data) {
    data.forEach((key, value) {
      _providerLibData[key] = value;
    });
    _notify();
    _persistSave!(_providerLibData);
  }
}
